#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main(int argc, char* argv[]) {
	int sockfd, connfd;
	struct sockaddr_in server_addr;
	struct sockaddr_in client_addr;
	int len = sizeof(server_addr);

	server_addr.sin_family = AF_INET;
	server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	server_addr.sin_port = htons(4567);

	sockfd = socket(AF_INET, SOCK_DGRAM, 0);
	connect(sockfd, (struct sockaddr*)&server_addr, len);

	
	char buf[100] = "Hello World!";
	sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr*)&server_addr, len);
	char rcv[100] = {0};
	recvfrom(sockfd, rcv, 100, 0, (struct sockaddr*)&server_addr, &len);	
	printf("cli_read: %s\n", rcv);
	
/*
	char buf[100] = "Hello World!";
	send(sockfd, buf, strlen(buf), 0);
	char rcv[100] = {0};
	recv(sockfd, rcv, 100, 0);	
	printf("cli_read: %s\n", rcv);
*/
	close(sockfd);
	return 0;
}
